﻿Imports System.Data.SqlClient
Public Class exspanding
    Dim cmd As New SqlCommand
    Public Sub refreshdata()
        condb()
        grdincom.Rows.Clear()
        cmd.Connection = cn
        cmd.CommandText = "select proname,Madedate,qty,pricein,SUM (qty*pricein)Total from tblProduct where Madedate between '" & startdate.Value & "' and '" & enddate.Value & "' group by proname,Madedate,qty,pricein"
        Dim dr = cmd.ExecuteReader()
        Dim dt As New DataTable
        While dr.Read = True
            grdincom.Rows.Add(dr(0), dr(1), dr(2), dr(3), dr(4))
        End While
        dr.Close()
    End Sub
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Try
            refreshdata()
            ' for total invoice............
            cmd.Connection = cn
            cmd.CommandText = "select count (*) from tblproduct where Madedate between '" & startdate.Value & "' and  '" & enddate.Value & "'"
            Dim invoice = cmd.ExecuteScalar
            lbltotalinvoice.Text = invoice

            'for Total Amonut 
            cmd.Connection = cn
            cmd.CommandText = " select SUM (qty*pricein) from tblproduct where Madedate between '" & startdate.Value & "' and  '" & enddate.Value & "'"
            Dim totalamount = cmd.ExecuteScalar
            lbltotalamount.Text = totalamount
        Catch ex As Exception

            MessageBox.Show("this month you not have values", "Expanding statement info", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
        End Try
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        Dim frm As New expandingReport
        frm.ShowDialog()
    End Sub

    Private Sub exspanding_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        condb()
    End Sub
End Class